package core

import (
	"KumquatDrivesServices/conf"
	"KumquatDrivesServices/flags"
	"fmt"
	"log"
	"os"

	"gopkg.in/yaml.v3"
)

func ReadConf() *conf.Config {
	log.Print("读取配置文件...")
	byteDate, err := os.ReadFile(flags.FlagsOptions.File)
	if err != nil {
		panic(err)
	}
	var conf conf.Config
	if err := yaml.Unmarshal(byteDate, &conf); err != nil {
		panic(fmt.Sprintf("yaml配置文件错误：%v", err))
	}
	conf.Jwt.Init()
	log.Print("配置文件读取成功")
	return &conf
}
